import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;


public class Reader implements Runnable {
	private Socket s ;
	private String message ;
	public Reader(Socket sock, String message){
		s = sock ;
		this.message = message ;
		new Thread(this).start() ;
	}
	
	public void run() {
		InputStreamReader reader;
		try {
			reader = new InputStreamReader(s.getInputStream());
			BufferedReader br = new BufferedReader(reader) ;
			String line ;
			boolean ok = true ;
			while (((line = br.readLine()) != null) && ok==true) {
				if (line.equals(message)) {
					System.out.println(line);
					break;
				}
			}	
			br.close() ;
			s.close() ;
			System.exit(0) ;
		} catch (IOException e) {
			e.printStackTrace();
		}
		

	}

}
